.class public Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;
.super Ljava/lang/Object;
.source "LineCollectionManager.java"


# instance fields
.field private dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .locals 1
    .parameter "context"

    .prologue
    .line 15
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 16
    new-instance v0, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-direct {v0, p1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    .line 17
    return-void
.end method


# virtual methods
.method public delete(Ljava/lang/Integer;)V
    .locals 4
    .parameter "id"

    .prologue
    .line 37
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 38
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from line_collection where _id =?"

    const/4 v2, 0x1

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    aput-object p1, v2, v3

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 39
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 40
    return-void
.end method

.method public deleteAll()V
    .locals 3

    .prologue
    .line 47
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 48
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "delete from line_collection "

    const/4 v2, 0x0

    new-array v2, v2, [Ljava/lang/Object;

    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 49
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 50
    return-void
.end method

.method public find(Ljava/lang/Integer;)Lcom/teewoo/app/bus/model/collection/LineCollection;
    .locals 9
    .parameter "id"

    .prologue
    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 97
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v8

    .line 98
    .local v8, database:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v0, 0x0

    .line 100
    .local v0, tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    const-string v1, "select * from line_collection where _id = ?"

    .line 101
    new-array v2, v5, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    aput-object v3, v2, v4

    .line 99
    invoke-virtual {v8, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v7

    .line 103
    .local v7, cursor:Landroid/database/Cursor;
    invoke-interface {v7}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 104
    new-instance v0, Lcom/teewoo/app/bus/model/collection/LineCollection;

    .end local v0           #tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    invoke-interface {v7, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-interface {v7, v5}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    const/4 v3, 0x2

    invoke-interface {v7, v3}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v3

    const/4 v4, 0x3

    invoke-interface {v7, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    .line 105
    const/4 v5, 0x4

    invoke-interface {v7, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x5

    invoke-interface {v7, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 104
    invoke-direct/range {v0 .. v6}, Lcom/teewoo/app/bus/model/collection/LineCollection;-><init>(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    .line 108
    .restart local v0       #tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    :cond_0
    invoke-interface {v7}, Landroid/database/Cursor;->close()V

    .line 109
    invoke-virtual {v8}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 110
    return-object v0
.end method

.method public findByProperty(Ljava/lang/Integer;Ljava/lang/Integer;)Lcom/teewoo/app/bus/model/collection/LineCollection;
    .locals 9
    .parameter "lineId"
    .parameter "stationId"

    .prologue
    const/4 v6, 0x2

    const/4 v5, 0x1

    const/4 v4, 0x0

    .line 57
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v8

    .line 58
    .local v8, database:Landroid/database/sqlite/SQLiteDatabase;
    const/4 v0, 0x0

    .line 59
    .local v0, tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    const-string v1, "select * from line_collection where line_id = ? and station_id= ? "

    new-array v2, v6, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    aput-object v3, v2, v4

    invoke-static {p2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    aput-object v3, v2, v5

    invoke-virtual {v8, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v7

    .line 61
    .local v7, cursor:Landroid/database/Cursor;
    invoke-interface {v7}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v1

    if-eqz v1, :cond_0

    .line 62
    new-instance v0, Lcom/teewoo/app/bus/model/collection/LineCollection;

    .end local v0           #tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    invoke-interface {v7, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-interface {v7, v5}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-interface {v7, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v3

    const/4 v4, 0x3

    invoke-interface {v7, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    .line 63
    const/4 v5, 0x4

    invoke-interface {v7, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x5

    invoke-interface {v7, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    .line 62
    invoke-direct/range {v0 .. v6}, Lcom/teewoo/app/bus/model/collection/LineCollection;-><init>(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    .line 71
    .restart local v0       #tempColl:Lcom/teewoo/app/bus/model/collection/LineCollection;
    :cond_0
    invoke-interface {v7}, Landroid/database/Cursor;->close()V

    .line 72
    invoke-virtual {v8}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 73
    return-object v0
.end method

.method public getScrollData(II)Ljava/util/List;
    .locals 13
    .parameter "startResult"
    .parameter "maxResult"
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(II)",
            "Ljava/util/List",
            "<",
            "Lcom/teewoo/app/bus/model/collection/LineCollection;",
            ">;"
        }
    .end annotation

    .prologue
    const/4 v12, 0x2

    const/4 v11, 0x1

    const/4 v10, 0x0

    .line 121
    new-instance v9, Ljava/util/ArrayList;

    invoke-direct {v9}, Ljava/util/ArrayList;-><init>()V

    .line 122
    .local v9, list:Ljava/util/List;,"Ljava/util/List<Lcom/teewoo/app/bus/model/collection/LineCollection;>;"
    iget-object v0, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v0}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getReadableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v8

    .line 125
    .local v8, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v0, "select * from line_collection ORDER BY save_time DESC limit ?,?"

    .line 126
    new-array v1, v12, [Ljava/lang/String;

    invoke-static {p1}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v2

    aput-object v2, v1, v10

    .line 127
    invoke-static {p2}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v2

    aput-object v2, v1, v11

    .line 124
    invoke-virtual {v8, v0, v1}, Landroid/database/sqlite/SQLiteDatabase;->rawQuery(Ljava/lang/String;[Ljava/lang/String;)Landroid/database/Cursor;

    move-result-object v7

    .line 129
    .local v7, cursor:Landroid/database/Cursor;
    invoke-interface {v7}, Landroid/database/Cursor;->moveToFirst()Z

    move-result v0

    if-eqz v0, :cond_1

    .line 131
    :cond_0
    new-instance v0, Lcom/teewoo/app/bus/model/collection/LineCollection;

    invoke-interface {v7, v10}, Landroid/database/Cursor;->getInt(I)I

    move-result v1

    invoke-static {v1}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v1

    invoke-interface {v7, v11}, Landroid/database/Cursor;->getInt(I)I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    invoke-interface {v7, v12}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v3

    const/4 v4, 0x3

    invoke-interface {v7, v4}, Landroid/database/Cursor;->getInt(I)I

    move-result v4

    invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v4

    .line 132
    const/4 v5, 0x4

    invoke-interface {v7, v5}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v5

    const/4 v6, 0x5

    invoke-interface {v7, v6}, Landroid/database/Cursor;->getString(I)Ljava/lang/String;

    move-result-object v6

    invoke-direct/range {v0 .. v6}, Lcom/teewoo/app/bus/model/collection/LineCollection;-><init>(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;)V

    .line 131
    invoke-interface {v9, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 133
    invoke-interface {v7}, Landroid/database/Cursor;->moveToNext()Z

    move-result v0

    .line 130
    if-nez v0, :cond_0

    .line 136
    :cond_1
    invoke-interface {v7}, Landroid/database/Cursor;->close()V

    .line 137
    invoke-virtual {v8}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 138
    return-object v9
.end method

.method public save(Lcom/teewoo/app/bus/model/collection/LineCollection;)V
    .locals 5
    .parameter "lineCol"

    .prologue
    .line 25
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 26
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "insert into line_collection ( line_id, line_name, station_id, station_name, save_time) values ( ?, ?, ?, ?, ?);"

    .line 27
    const/4 v2, 0x5

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getLineId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getLineName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getStationId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x3

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getStationName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x4

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getSaveTime()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    .line 26
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 28
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 29
    return-void
.end method

.method public update(Lcom/teewoo/app/bus/model/collection/LineCollection;)V
    .locals 5
    .parameter "lineCol"

    .prologue
    .line 82
    iget-object v1, p0, Lcom/teewoo/app/bus/manager/collection/LineCollectionManager;->dbInstance:Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;

    invoke-virtual {v1}, Lcom/teewoo/app/bus/db/collection/LineCollectionDBHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v0

    .line 83
    .local v0, database:Landroid/database/sqlite/SQLiteDatabase;
    const-string v1, "update line_collection set line_id = ?,line_name = ?, station_id = ?, station_name = ?, save_time = ? where _id=?"

    .line 84
    const/4 v2, 0x5

    new-array v2, v2, [Ljava/lang/Object;

    const/4 v3, 0x0

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getLineId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x1

    .line 85
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getStationId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x2

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getLineName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x3

    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getStationName()Ljava/lang/String;

    move-result-object v4

    aput-object v4, v2, v3

    const/4 v3, 0x4

    .line 86
    invoke-virtual {p1}, Lcom/teewoo/app/bus/model/collection/LineCollection;->getId()Ljava/lang/Integer;

    move-result-object v4

    aput-object v4, v2, v3

    .line 83
    invoke-virtual {v0, v1, v2}, Landroid/database/sqlite/SQLiteDatabase;->execSQL(Ljava/lang/String;[Ljava/lang/Object;)V

    .line 87
    invoke-virtual {v0}, Landroid/database/sqlite/SQLiteDatabase;->close()V

    .line 88
    return-void
.end method
